﻿<UserControl x:Class="nRoute.Samples.Netflix.Views.GenresListingView" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:n="http://nRoute/schemas/2010/xaml"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
	xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
    xmlns:local_Controls="clr-namespace:nRoute.Samples.Netflix.Controls" 
	d:DesignHeight="600" d:DesignWidth="320" 
	n:Navigation.Title="Genres Listing"
    mc:Ignorable="d">
	
	<UserControl.Resources>
		<n:ValueConverterRelay x:Key="TitleQueryConverter" />
	</UserControl.Resources>

    <i:Interaction.Behaviors>
        <n:BridgeViewModelBehavior LoadedCommand="{Binding LoadDataCommand}"/>
        <n:BridgeValueConverterBehavior ValueConverterRelay="{DynamicResource TitleQueryConverter}" 
			ConverterSource="{Binding GenreToTitleQueryConverter}"/>
    </i:Interaction.Behaviors>

    <Grid x:Name="LayoutRoot" Background="White">
    	
    	<Grid.RowDefinitions>
	        <RowDefinition Height="Auto"/>
	        <RowDefinition/>
	        <RowDefinition Height="60"/>
	    </Grid.RowDefinitions>
			<ListBox x:Name="DataListBox" BorderThickness="0,0,1,0" Padding="0" 
				ItemsSource="{Binding Genres}" Grid.Row="1" 
				ItemTemplate="{StaticResource TopicTitleTemplate}" 
				ItemContainerStyle="{StaticResource TopicTitleBoxItemStyle}" 
				ScrollViewer.HorizontalScrollBarVisibility="Disabled"
				ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0">
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="SelectionChanged">						
						<i:Interaction.Behaviors>
							<ei:ConditionBehavior>
								<ei:ConditionalExpression>
									<ei:ComparisonCondition LeftOperand="{Binding SelectedIndex, ElementName=DataListBox}" Operator="NotEqual" RightOperand="-1"/>
								</ei:ConditionalExpression>
							</ei:ConditionBehavior>
						</i:Interaction.Behaviors>						
						<n:NavigateAction HandlerName="ContentContainer" Url="Content/Netflix/Titles/" >
							<n:DependencyParameter Key="MovieQuery" 
								Value="{Binding SelectedItem, Converter={StaticResource TitleQueryConverter}, ElementName=DataListBox}"/>
							<n:DependencyParameter Key="PageTitle">
								<n:DependencyParameter.Value>
									<Binding Path="SelectedItem.Name" ElementName="DataListBox" StringFormat="Titles in Genre: {0}" />
								</n:DependencyParameter.Value>
							</n:DependencyParameter>								
						</n:NavigateAction>						
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</ListBox>
			<Border Height="40" BorderBrush="#FF81868F" BorderThickness="0,0,1,0">				
				<i:Interaction.Behaviors>
					<n:BoolValueVisibilityBehavior Value="{Binding IsSearching}"/>
				</i:Interaction.Behaviors>
				<Grid Margin="12,0,1,0">				
					<TextBlock Margin="8,-3,42,0" TextWrapping="NoWrap" 
						Text="{Binding SearchText, FallbackValue=Search Results, StringFormat='Results for ΄{0}΄' }" 
						FontSize="16" Foreground="#FF8D8D8D" TextTrimming="WordEllipsis" 
						FontFamily="Segoe UI Light" d:LayoutOverrides="Height" VerticalAlignment="Center"/>
					<Button Style="{DynamicResource ChromeButtonStyle}" HorizontalAlignment="Right" Height="15" 
						Margin="0,0,12.396,0" VerticalAlignment="Center" Width="15" >
						<i:Interaction.Triggers>
							<i:EventTrigger EventName="Click">
								<n:ExecuteCommandAction Command="{Binding ClearSearchCommand}"/>
							</i:EventTrigger>
						</i:Interaction.Triggers>
						<Path Data="M7.9099998,7.4159999 L19.179824,20.778801 M19.40935,7.4540897 L7.9139289,20.582763" 
							Stretch="Fill" Stroke="#FF8D8D8D" 
							UseLayoutRounding="False" RenderTransformOrigin="0.160137526446591,0.114919132408156"/>
					</Button>
					<!--<Path Data="M16.581301,11.680997 C16.581301,14.418091 14.344331,16.636944 11.584888,16.636944 8.8254444,16.636944 6.5884738,14.418091 6.5884738,11.680997 6.5884738,8.9439026 8.8254444,6.7250495 11.584888,6.7250495 14.344331,6.7250495 16.581301,8.9439026 16.581301,11.680997 z M14.716612,15.63386 L19.088474,20.22505 M2.4644043,19.056007 C5.669659,25.014041 13.097973,27.24561 19.056007,24.040355 25.014041,20.8351 27.24561,13.406787 24.040355,7.4487528 20.835101,1.4907184 13.406787,-0.74085041 7.4487528,2.4644043 1.4907186,5.6696589 -0.74085034,13.097972 2.4644043,19.056007 z" 
						HorizontalAlignment="Left" Margin="8,0,0,0" Stretch="Fill" Stroke="#FF8D8D8D" 
						UseLayoutRounding="False" Width="26.505" VerticalAlignment="Center" 
						Height="26.504" RenderTransformOrigin="0.484383698185273,0.508401108359125" Fill="#00000000" Visibility="Collapsed"/>-->
				</Grid>
			</Border>
			
			<local_Controls:WorkingIndicator IsWorking="{Binding IsLoading}" Grid.RowSpan="3" d:IsHidden="True"/>
    </Grid>
    
</UserControl>
